home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
postogrf.zip
/
COPYBLOC.INC
< prev
next >
Wrap
Text File
|
1990-06-04
|
34KB
|
918 lines
{ program CopyBlock.inc
written by Thomas B. Passin in Turbo Pascal 4.0.
For use in POSTogrf/LIPSogrf. Shows, resizes, and moves an open
rectangle. This represents the allowed size of the graph when printed
(e.g., 8 X 6.25 in for a MITRE report). When the box is located in
the upper left corner of the screen, the box represents the copybox
as located at the printer margin. If the box is moved away from the
corner, it shows whether the graph can be cropped to fit inside the box.
22 May 90 Other sections of code have also been moved here:
procedures Repaint1, MoveLabel, Attributes.
27 Apr 89 Now XOR's the box when moving.
18 Oct 88 v1.0x4. Added var noshow to toggle rectangle on or off:
modified CopyBlock, CopyBlockMenu.
20 Sept 88. v1.0x3. Surounded each readln by textcolor(white),
textcolor(black) pairs. Needed to overcome BGI bug.
Changed type colors to word to avoid collision with
CRT unit.
14 Sept 88. v1.0x2. Added HOME key to MoveCopyBlock: takes box to upper
left corner. Added HOME to set of Movers in CopyBlockMenu.
13 Sept 88. v1.0x1. Works.
}
(*{$DEFINE test}*)
{$IFDEF test}
uses graph, CRT;
type videocolors = (color, mono);
{mcolors = (yellow, white, black);}
colors = word;
string80 = string[80];
const ESC = #27; BS = #8; CR = #13; LF = #10;
Uparrow = #72; Downarrow = #80;
Leftarrow = #75; Rightarrow = #77;
Del = #83; Ins = #82;
Home = #71; En = #79;
PF1 = #59; PF2 = #60; PF3 = #61; PF4 = #62; PF5 = #63;
PF6 = #64; PF7 = #65; PF8 = #66; PF9 = #67; PF10 = #68;
var VidCol :videocolors;
key :char;
procedure ScrConv(x,y:integer); begin end; { dummy procedures for debugging }
procedure SetColor(cc:colors); begin end;
procedure repaint; begin end;
{$ENDIF}
{ ---------------------------------------------------------------------
Part of the RePaint procedure
--------------------------------------------------------------------- }
Procedure RePaint1;
var savePrtSize: integer;
t1: integer;
begin
here := JimFileStart;
SavePrtSize := TempText.PrtSize;
SetColor(white);
t1:= 10; SetPrtFontSize(t1);
SetTextStyle(SansSerifFont,Horizdir,UserCHarSize);
done := false;
if count > 0 then Repeat DrawJimFile until done ;
if VidCol = color then SetColor(yellow) else SetColor(white);
Line(0,GetMaxY - 3*LinesPerChar,GetMaxX,GetMaxY-3*LinesPerChar);
if head = nil then exit;
cp := head;
repeat
showLabel(cp, white);
cp := cp^.link;
until cp = nil;
if select <> nil then HighLight(select);
if LConfig.DoBar then DoVGBar;
RestorePrtFontSize(SavePrtSize);
TempText := select^;
SetUpLabel(select);
end;
{ ------------------------------------------------------------------------
Size the copyblock to fit the graph
------------------------------------------------------------------------ }
procedure AutoSizeCopyBlock;
var maxMinRect: rect; {accumulate max, min corners}
x1, x2, y1, y2: integer;
cpx, cpy : integer; {current point in Postscript coords}
procedure DoRectMaxMin(x,y: integer; var r: rect);
begin
with r do begin
if x < LLx then LLx := x else
if x > URx then URx := x;
if y < LLy then LLy := y else
if y > URy then URy := y;
end;
end;
procedure SizeJimFile;
var XPos, Ypos, error, temp : integer;
PenDia : word;
n1 : word;
str : string80;
sFlag : boolean;
begin
GetAWord(str);
case GraphFile of
GRAPHL, LIPSGRF: begin
(*if str = 'EXIT' then begin done := true; exit ; end ELSE
if str = 'MAP' then { move to position }
begin GetAWord(str); Val(str,Xpos,error);
GetAWord(str); Val(str,Ypos,error);
ScrConv(XPos, YPos);
MoveTo(Xpos,YPos);
end ELSE
if str = 'DAP' then { draw to position }
begin GetAWord(str); Val(str,Xpos,error);
GetAWord(str); Val(str,Ypos,error);
ScrConv(XPos,YPos);
LineTo(Xpos,YPos);
end ELSE
if str = 'SPD' then {set pen diameter - only an approximation }
begin GetAWord(str); Val(str,PenDia, error);
PenDia := word(round(10 * PenDia/VPrtScale)) div 3;
SetLineStyle(0,0,PenDia);
end ELSE
if str = 'FONT' then {he asks for internal landscape font - fake it }
begin GetAWord(str);
if str = '3' then begin
temp:= 12; SetPrtFontSize(temp);
end; {else;}
end ELSE
if str = 'TEXT' then begin {write the following text string }
GetAQuote(str); OutText(str);
end ELSE {nothing} *)
end; {case GRAPHL, LIPSGRF}
POSTSCRIPT: begin
temp := 13; SetPrtFontSize(temp);
if str[1] = 's' then sFlag := true else sFlag := false;
if str[1] = '%' then
repeat
inc(here)
until (JimFile^[here] = CR) or (JimFile^[here] = LF);
if str[1] = '(' then begin {found a label}
ParsePSstring(str,mark);
x1 := textwidth(str);
y1 := textheight(str);
x1 := round(x1/Hscale);
y1 := round(y1/VScale);
doRectMaxMin(cpx - 50, cpy, maxMinRect);
doRectmaxMin(cpx + x1 ,cpy +50 + y1 + y1 div 2, maxMinRect);
here := mark;
end ELSE
if (str[1] = 'm') then begin
if ((str = 'm') or (str = 'moveto')) then begin
n1 := here - 1;
GetAWordBack(str,n1); GetAWordBack(str, n1);
Val(str, YPos, error);
if error <> 0 then exit;
GetAWordBack(str,n1);
Val(str,XPos,error);
if error <> 0 then exit;
cpx := Xpos; cpy := Ypos;
doRectMaxMin(cpx, cpy, maxMinRect);
end;
end ELSE
if (str[1] = 'l') then begin
if ((str = 'l') or (str = 'lineto')) then begin
n1 := here - 1;
GetAWordBack(str,n1); GetAWordBack(str, n1);
Val(str, YPos, error);
GetAWordBack(str,n1);
Val(str,XPos,error);
cpx := Xpos; cpy := Ypos;
doRectMaxMin(cpx, cpy, maxMinRect);
end;
end ELSE if
(sflag) and (str = 'setlinewidth') then begin
{n1 := here -1; GetAWordBack(str,n1); GetAWordBack(str, n1);
Val(str,PenDia,error);
if error = 0 then
PenDia := word(round(PenDia)) div 10;
else PenDia := 1;
SetLineStyle(0,0,PenDia);}
end ELSE if (sFlag) and (str = 'sf') then begin
{set active font size}
{any labels here are default 13 pt labels}
temp := 13; SetPrtFontSize(temp);
end ELSE if (sFlag) and (str = 'setfont') then begin
{temp := 13; SetPrtFontSize(temp);}
end ELSE if (sFlag) and (str = 'showpage') then begin
done := true; exit ;
end; {if..ELSE}
end; {POSTSCRIPT}